#pragma once

#include "TurnGenerator.h"
#include "Serializable.h"
#include "Team.h"

#include "StlStringAndStreams.h"

class ServiceProvider;

class LeagueCalendar : public Serializable
{
public:
	
	explicit LeagueCalendar(ServiceProvider* i_sp);

	void Clear();
	void Initialize(TeamVec& i_teamList);

	void CreateNextTurn(MatchDataVec& o_matches) const;

	const size_t GetTurnNumber() const;

	virtual	ZStream& Serialize(ZStream& o_stream) const;
	virtual ZStream& Deserialize(ZStream& i_stream);

	const TeamVec& GetTeamList() const;
	const TurnGenerator& GetTurnGenerator() const;

private:
	LeagueCalendar(const LeagueCalendar&);
	LeagueCalendar& operator=(const LeagueCalendar&);

	void FillMatches(const size_t i_turnNumber, MatchDataVec& o_matches) const;

	TurnGenerator m_turnGen;
	mutable size_t m_currentTurn;
	TeamVec* m_teamList;
	ServiceProvider* m_sp;
};

inline const TeamVec& LeagueCalendar::GetTeamList() const
{
	return *m_teamList;
}

inline const TurnGenerator& LeagueCalendar::GetTurnGenerator() const
{
	return m_turnGen;
}

inline void LeagueCalendar::CreateNextTurn(MatchDataVec& o_matches) const
{
	FillMatches(m_currentTurn++, o_matches);
}

inline const size_t LeagueCalendar::GetTurnNumber() const
{
	return m_currentTurn;
}

